import { fileURLToPath } from 'node:url';
import { configDefaults, defineConfig, mergeConfig } from 'vitest/config';
import viteConfig from './vite.config';

export default defineConfig(configEnv =>
  mergeConfig(
    viteConfig(configEnv),
    defineConfig({
      test: {
        environment: 'jsdom',
        exclude: [...configDefaults.exclude, 'e2e/**'],
        root: fileURLToPath(new URL('./', import.meta.url)),
        deps: {
          inline: ['vue'], // 如果被测试的内容有包含vue的，需要配置这个
        },
        coverage: {
          reporter: ['text', 'json', 'html'],
          include: ['**/logics/*.ts'],
          exclude: ['**/node_modules/**', '**/tests/**'],
          thresholds: {
            lines: 100, // 行覆盖率
            functions: 100, // 函数覆盖率
            branches: 100, // 分支覆盖率
            statements: 100, // 语句覆盖率
          },
        },
      },
    }),
  ),
);
